package com.jjwxc.jwjskandriod.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.widget.TextView;

import com.jjwxc.jwjskandriod.R;
import com.jjwxc.jwjskandriod.config.BaseActivity;

public class AboutActivity extends BaseActivity {
    private TextView tv_version;

    @Override
    public int getContentViewId() {
        return R.layout.activity_about;
    }

    @Override
    public void findView() {
        setTitle("关于碧水全本小说");
        tv_version = findViewById(R.id.tv_version);
    }

    @Override
    public void setListener() {

    }

    @SuppressLint("SetTextI18n")
    @Override
    public void afterCreate() {
        tv_version.setText("v"+getVerName(AboutActivity.this));
    }

    /**
     * 获取版本号名称
     *
     * @param context 上下文
     * @return
     */
    public static String getVerName(Context context) {
        String verName = "1.0.0";
        try {
            verName = context.getPackageManager().
                    getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return verName;
    }

}
